package com.luisliuyi.demo.optimize.crash;

import android.app.Application;
import android.util.Log;

import com.luisliuyi.lib.crash.CrashHandler;
import com.luisliuyi.lib.crash.CrashListener;
import com.luisliuyi.lib.crash.tool.CrashHelper;
import com.luisliuyi.lib.crash.tool.CrashToolUtils;

public class CrashApplication extends Application {
    private String TAG = "CrashApplication";

    @Override
    public void onCreate() {
        super.onCreate();
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
        Log.e(TAG, "onCreate: "+uncaughtExceptionHandler);
        CrashHelper.getInstance().setExceptionHandler(new CrashExceptionHandler());
        CrashHandler.getInstance().setWriteLog(true).setFinishActivity(true).init(this, new CrashListener() {

            @Override
            public void againStartApp() {
//                CrashToolUtils.reStartApp1(getApplicationContext(),2000);
//                CrashToolUtils.reStartApp3(getApplicationContext());
            }

            /**
             * 上传方案设定
             * @param ex  ex
             */
            @Override
            public void recordException(Throwable ex) {
                //具体数据拼装和上传！
            }
        });
    }

}
